<template>
  <el-col :span="22" :offset="1">
  <el-card>
    <el-table
      :data="wages"
      style="width: 100%"
      max-height="370">
      <el-table-column
        fixed
        prop="sId"
        label="员工id"
        width="auto">
      </el-table-column>
      <el-table-column
        prop="salaryMonth"
        label="薪水发放时间"
        width="auto">
      </el-table-column>
      <el-table-column
        prop="projectBonus"
        label="项目绩效"
        width="auto">
      </el-table-column>
      <el-table-column
        prop="baseSalary"
        label="基本工资"
        width="auto">
      </el-table-column>
      <el-table-column
        prop="checkOn"
        label="考勤"
        width="auto">
      </el-table-column>

      <el-table-column
        prop="sum"
        label="总计"
        width="auto">
      </el-table-column>

      <el-table-column
        label=""
        width="50">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleEdit(scope.$index,wages)">编辑</el-button>
        </template>
      </el-table-column>

      <el-table-column
        label=""
        width="50">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="deleteRow(scope.$index,wages)">删除</el-button>
        </template>
      </el-table-column>·

    </el-table>
    <template>
      <el-dialog title="修改绩效信息"  width="40%" :visible.sync="dialogFormVisible">
        <el-form ref="form" :model="form" label-width="100px">
          <el-form-item size="small" label="工作质量">
            <el-input size="small" v-model="form.sQuality"></el-input>
          </el-form-item>
          <el-form-item size="small" label="考勤">
            <el-input size="small" v-model="form.sCheckIn"></el-input>
          </el-form-item>
          <el-form-item size="small" label="发放时间">
            <el-input size="small" v-model="form.sSalaryTime"></el-input>
          </el-form-item>

          <el-form-item size="small" label="评价">
            <el-input size="small" v-model="form.sEvaluation"></el-input>
          </el-form-item>
          <el-form-item size="small" label="发放状态">
            <el-input size="small" v-model="form.sStatus"></el-input>
          </el-form-item>
        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取消</el-button>
          <el-button type="primary" @click="saveEdit">确认修改</el-button>
          <!--                <el-button type="primary" @click="dialogFormVisible = false">确认修改</el-button>-->
        </div>
      </el-dialog>
    </template>
  </el-card>
    <el-card style="margin-top: 10px">
      <el-button type="info" style="margin-left: 10px" @click="print">打印绩效报表</el-button>
    </el-card>
  </el-col>
</template>

<script>
  import Global from '../../utils/global'
  export default {
    name: 'WageManageSuper',
    data(){
      return{
        idx:-1,
        glo:new Global,
        wages:[],
        form:{
          sId:null,
          salaryMonth:null,
          projectBonus:null,
          baseSalary:null,
          checkOn:null,
          sum:null,
        },
        input4search:'',
        dialogFormVisible: false,
      }
    },
    methods:{
      print(){
        var timestamp = (new Date()).valueOf();
        var token = md5("epms" + timestamp);
        window.open("http://47.92.227.185:8080/download/wageCsv?token="+token+"&timestamp="+timestamp)
        // var data = {}
        // this.glo.sendDate(this.glo.server+'download/wageCsv',data,null,"POST")
      },
      inserTable (line) {
        this.wages.push(
          {
            sId: line.sId,
            salaryMonth:line.salaryMonth,
            projectBonus:line.projectBonus,
            baseSalary:line.baseSalary,
            checkOn:line.checkOn,
            sum:line.sum,
          }
        )
      },
      initWagePage (res) {
        console.log(res)
        for (var line in res.data.wageList){
          this.inserTable(res.data.wageList[line])
        }
      },
      handleRes (res) {
        console.log(res);
        let feedBack = eval(res);
        if (feedBack.success == false) {//登录失败
          this.$message("绩效列表获取失败");
          return;
        }
        this.$message.success("绩效列表获取成功^^")
        this.initWagePage(feedBack)
      },

    },
    mounted(){
      let data = {
        sId:JSON.parse(sessionStorage.getItem('StaffInfo')).sId
      }
      this.glo.sendDate(this.glo.server+'admin/getAllWage',data,this.handleRes,"POST")
    },
  }
</script>

<style scoped>

</style>
